export default {
  data() {
    return {
      screenWidth :0,
      fixedHeight: 400,
      bannerHeight: 400,
    }
  },
  mounted() {
    this.fixedHeight = this.bannerHeight
    this.screenWidth =  window.innerWidth
    this.setSize()
    // 窗口大小发生改变时,调用一次
    window.onresize = () => {
      this.screenWidth =  window.innerWidth
      this.setSize()
    }
  },
  methods: {
    setSize () {
      // 通过浏览器宽度(图片宽度)计算高度
      if(this.screenWidth < 1080) return
      this.bannerHeight = this.fixedHeight / 1550 * this.screenWidth
    }
  }
}